<?php
/**
 * @brief get_user_data protocol
 *
 * @param post uid User Id
 * @return all info for user
 * @author con100 <con100@playplus.net>
 * @since 09/04/2013
 * @copyright Copyright (c) 2013, PlayPlus
 **/

include 'dbconn.php';

$user_id = mysql_real_escape_string($_POST['uid']);

$sql = "select no, name, level, money, cash, nation, king, exp, max_exp, hp, max_hp, timestemp_hp, en, max_en, timestemp_en, timestemp_rest, 
			timestemp_active, timestemp_free, timestemp_moon, sp_atk, sp_hit, sp_def, sp_spd, killer_no, comment from ebs_member where id='$user_id'";
$res = mysql_query($sql);
if(!$data = mysql_fetch_assoc($res)){
	$result = array("Result"=>FALSE);
}
else{
	$result = array("Result"=>TRUE, "user_no"=>$data['no'], "nick"=>$data['name'], "level"=>$data['level'], "money"=>$data['money'], "cash"=>$data['cash'], "nation"=>$data['nation'], "king"=>$data['king'],
				"exp"=>$data['exp'], "max_exp"=>$data['max_exp'], "hp"=>$data['hp'], "max_hp"=>$data['max_hp'], "timestamp_hp"=>$data['timestemp_hp'], "en"=>$data['en'], "max_en"=>$data['max_en'], 
				"timestamp_en"=>$data['timestemp_en'], "timestamp_rest"=>$data['timestemp_rest'], "timestamp_active"=>$data['timestemp_active'], "timestamp_free"=>$data['timestemp_free'], 
				"timestamp_moon"=>$data['timestemp_moon'],"sp_atk"=>$data['sp_atk'], "sp_hit"=>$data['sp_hit'], "sp_def"=>$data['sp_def'], "sp_spd"=>$data['sp_spd'], "killer_no"=>$data['killer_no'], 
				"comment"=>$data['comment']);
}
echo json_encode($result);
/*
header('Content-type: text/xml; charset=UTF-8');

$writer = new XMLWriter();
$writer->openMemory();
$writer->setIndent(true);
$writer->setIndentString('  ');
$writer->startDocument('1.0', 'UTF-8');

$writer->startElement('login');
	$writer->startElement('result');
	$writer->text($result);
	$writer->endElement();
	if($result == "TRUE"){
		$writer->startElement('no');
		$writer->text($data['no']);
		$writer->endElement();
		$writer->startElement('name');
		$writer->text($data['name']);
		$writer->endElement();
		$writer->startElement('level');
		$writer->text($data['level']);
		$writer->endElement();
		$writer->startElement('money');
		$writer->text($data['money']);
		$writer->endElement();
		$writer->startElement('result');
		$writer->text($data['name']);
		$writer->endElement();
		$writer->startElement('cash');
		$writer->text($data['cash']);
		$writer->endElement();
		$writer->startElement('nation');
		$writer->text($data['nation']);
		$writer->endElement();
		$writer->startElement('king');
		$writer->text($data['king']);
		$writer->endElement();
		$writer->startElement('exp');
		$writer->text($data['exp']);
		$writer->endElement();
		$writer->startElement('max_exp');
		$writer->text($data['max_exp']);
		$writer->endElement();
		$writer->startElement('hp');
		$writer->text($data['hp']);
		$writer->endElement();
		$writer->startElement('max_hp');
		$writer->text($data['max_hp']);
		$writer->endElement();
		$writer->startElement('timestemp_hp');
		$writer->text($data['timestemp_hp']);
		$writer->endElement();
		$writer->startElement('en');
		$writer->text($data['en']);
		$writer->endElement();
		$writer->startElement('max_en');
		$writer->text($data['max_en']);
		$writer->endElement();
		$writer->startElement('timestemp_en');
		$writer->text($data['timestemp_en']);
		$writer->endElement();
		$writer->startElement('timestemp_rest');
		$writer->text($data['timestemp_rest']);
		$writer->endElement();
		$writer->startElement('timestemp_active');
		$writer->text($data['timestemp_active']);
		$writer->endElement();
		$writer->startElement('timestemp_free');
		$writer->text($data['timestemp_free']);
		$writer->endElement();
		$writer->startElement('timestemp_moon');
		$writer->text($data['timestemp_moon']);
		$writer->endElement();
		$writer->startElement('sp_atk');
		$writer->text($data['sp_atk']);
		$writer->endElement();
		$writer->startElement('sp_hit');
		$writer->text($data['sp_hit']);
		$writer->endElement();
		$writer->startElement('sp_def');
		$writer->text($data['sp_def']);
		$writer->endElement();
		$writer->startElement('sp_spd');
		$writer->text($data['sp_spd']);
		$writer->endElement();
		$writer->startElement('killer_no');
		$writer->text($data['killer_no']);
		$writer->endElement();
		$writer->startElement('comment');
		$writer->text($data['comment']);
		$writer->endElement();
	}
$writer->endElement();
echo($writer->outputMemory());
*/
?>